import { useScreenStore } from "@/store/screen"
import { useSlidesStore } from "@/store/slides"
import { enterFullscreen, isFullscreen, exitFullscreen } from "@/utils/fullscreen"

export default () => {
  const slidesStore = useSlidesStore()
  const screenStore = useScreenStore()

  // 进入放映状态（从当前页开始）
  const enterScreening = () => {
    // 进入全屏模式
    enterFullscreen()
    screenStore.setScreening(true)
  }
  // 进入放映状态（从第一页开始）
  const enterScreeningFromStart = () => {
    slidesStore.updateSlideIndex(0)
    enterScreening()
  }

  // 退出放映状态
  const exitScreening = () => {
    screenStore.setScreening(false)
    if (isFullscreen()) exitFullscreen()
  }
  return {
    enterScreeningFromStart,
    enterScreening,
    exitScreening
  }
}